<% content_for :content do %>

  <!-- widget grid -->
  <section id="widget-grid" class="">

    <div class="row">
      <div class="col-sm-12">
        <div class="well">

          <%= simple_form_for :watching, url: admin_watchings_path, :defaults => { :input_html => { :class => "form-control" } }, method: 'get', html: { class: "form-inline" } do |f| %>
           <label>客户端编号</label>
           <%= f.input_field :client_id, value: params[:watching][:client_id] %>
           <label>账号</label>
           <%= f.input_field :account_id, value: params[:watching][:account_id] %>
           <label>创建时间</label>
           <div class="form-group string">
            <%= f.text_field :start_date, class: 'form-control datepicker', "data-dateformat" => "yy-mm-dd", value: params[:watching][:start_date], placeholder: "From" %>
           </div> 
           <div class="form-group string">
             <%= f.text_field :end_date, class: 'form-control datepicker', "data-dateformat" => "yy-mm-dd", value: params[:watching][:end_date], placeholder: "To" %>
           </div>
           <%= f.submit "搜索", :class => "btn btn-default"%>
          <% end %>

        </div> <!-- end well div -->

      </div>
    </div>
    
    <!-- row -->
    <div class="row">
      <!-- NEW WIDGET START -->
      <article class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
        

        <!-- Widget ID (each widget will need unique ID)-->
        <div class="jarviswidget jarviswidget-color-darken" id="wid-id-1" data-widget-editbutton="false" data-widget-colorbutton="false" data-widget-deletebutton="false">
          <!-- widget options:
          usage: <div class="jarviswidget" id="wid-id-0" data-widget-editbutton="false">

          data-widget-colorbutton="false"
          data-widget-editbutton="false"
          data-widget-togglebutton="false"
          data-widget-deletebutton="false"
          data-widget-fullscreenbutton="false"
          data-widget-custombutton="false"
          data-widget-collapsed="true"
          data-widget-sortable="false"

          -->
          <header>
            <span class="widget-icon"> <i class="fa fa-table"></i> </span>
            <h2>观看列表</h2>
          </header>

          <!-- widget div-->
          <div>

            <!-- widget edit box -->
            <div class="jarviswidget-editbox">
              <!-- This area used as dropdown edit box -->
            </div>
            <!-- end widget edit box -->
            
            <!-- widget content -->
            <div class="widget-body no-padding">

              <div class="alert alert-info no-margin">
                <span class="">
                  <i class="fa-fw fa fa-info"></i>共有<%= @watching.total_count %>条记录
                </span>
                <span class="col-md-offset">
                  <a class="btn btn-default btn-sm" href="<%= admin_watchings_path({format: :csv}.merge!(params)) %>">导出为CSV</a>
                </span>
              </div>

              <table class="table table-bordered table-striped">
                <thead>
                  <tr>
                    <th>节目名称</th>
                    <th>客户端编号</th>
                    <th>账号</th>
                    <th>SID</th>
                    <th>观看时长（S）</th>
                    <th>创建时间</th>
                  </tr>
                </thead>
                <tbody>
                <% @watching.each do |watching| %>
                  <tr id='<%= watching.id %>'>
                    <td>
                      <%= watching.television_name %>
                    </td>
                    
                    <td>
                      <%= watching.client_id %>
                    </td>
                    <td>
                      <%= watching.account.try(:mobile_number) %>
                    </td>
                    <td>
                      <%= watching.sid %>
                    </td>
                    <td>
                      <%= watching.seconds %>
                    </td>
                    <td>
                      <%= watching.created_at.stamp("2013-03-12 22:01:11") %>
                    </td>
                  </tr>
                <% end %>
                </tbody>
              </table>

              <div class="dt-row dt-bottom-row"><div class="row"><div class="col-sm-3"><div class="dataTables_info" id="datatable_fixed_column_info"></div></div><div class="col-sm-9 text-right"><%= paginate @watching %></div></div></div>

            </div>
            <!-- end widget content -->

          </div>
          <!-- end widget div -->

        </div>
        <!-- end widget -->
  
      </article>
      <!-- WIDGET END -->

    </div>
  
    <!-- end row -->
 
  </section>
  <!-- end widget grid -->
<% end %>